home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-02-09 | 122.2 KB | 4,133 lines |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- M F P 1
-
-
- A Multiple Field Processor
-
- and
-
- Related Tools
-
- for the
-
- Professional Developer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Copyright 1990 by Jerome G. Kahn, All rights reserved
- Produced Exclusively for Pride Software Advancement Corporation
- 3575 N.W. 31 Avenue Oakland Park, Florida 33309
-
- * Turbo C is a registered trademark of Borland International.
- * Lattice is a registered trademark of Lattice Inc.
- * Microsoft is a registered trademark of Microsoft Corporation.
-
- M F P 1
-
- TABLE OF CONTENTS
-
-
- PAGE DESCRIPTION
-
- 4 MFP1 License Statement
-
- 5 Installation
-
- Data Entry and User Input Functions
-
- 7 Function: MFP
-
- 8 MFP Field Definition
-
- 9 MFP List
-
- 10 - 11 MFP Data Entry Picture Formatting
-
- 12 MFP Field Editing Keys
-
- 13 MFP Pre and Post Validation
-
- 14 MFP Procedure List
-
- 15 - 19 MFP Example Listing
-
- 20 - 24 MFP Example Listing Narrative
-
- 25 MFP Run Time Error Messages
-
- 26 Function: MENU
-
- 27 MENU Item Definition
-
- MENU List
-
- MENU Color
-
- 28 MENU Help Text
-
- 29 MENU Example
-
- 30 Function: PIC
-
- 31 Function: SCRN
-
- 32 Function: INKEY
-
- 33 INKEY Keyboard Usage
-
- 34 INKEY Definitions
-
- 35 Function: GETKEY
-
- 36 Function: FLUSH
-
-
- M F P 1
-
- TABLE OF CONTENTS
-
- PAGE 2
-
-
- PAGE DESCRIPTION
-
- Data Entry and User Input Functions (continued)
-
- 37 Function: PAUSE
-
- 38 Function: FAST
-
- Screen Output Functions
-
- 40 Function: COLOR
-
- 41 Function: CUP
-
- 42 Function: GETCUP
-
- 43 Function: PRINT
-
- 44 Function: SAY
-
- 45 Function: BIOPUTC
-
- 46 Function: ESHOW
-
- Window Functions
-
- 48 Function: WINDOW_CREATE
-
- 49 Function: WINDOW_KILL
-
- 50 Function: WCLS
-
- 51 Function: BOX
-
- 52 Function: W_SWAP
-
- 53 Function: SCRSWP
-
- Buffer Manipulation Functions
-
- 55 Function: ZERO
-
- 56 Function: FILL
-
- 57 Function: CRC & CRC32
-
- Date and Time Functions
-
- 59 Function: DATE
-
- 60 Function: LDATE
-
- 61 Function: STR_JUL
-
-
- M F P 1
-
- TABLE OF CONTENTS
-
- PAGE 3
-
-
- PAGE DESCRIPTION
-
- Date and Time Functions (continued)
-
- 62 Function: JUL_STR
-
- 63 Function: CAL_JUL
-
- 64 Function: JUL_CAL
-
- 65 Function: STRTIME
-
- 66 Function: TIME_NUM
-
- Miscellaneuos Functions
-
- 68 Function: BRKOFF & BRKON
-
- 70 Function: SCRSAVE & NOSAVE
-
- 71 Function: SHOWCLOK & NOCLOK
-
- 72 Function: DELAY
-
- MFP1 License Statement
-
- This software is protected by both United States copyright law and
- international treaty provisions. You, as a professional developer, know
- better than any others what that means. You don't want your software
- proliferated by others without any remuneration for your efforts any more
- than we do. We ask that you respect our rights and in return we will pro-
- vide you the best support and products to make you more productive.
-
- This is a special shareware release of the complete MFP1 library.
- You are required to register your copy with us at Pride if you wish to
- distribute any software linked with the MFP1 library. You are NOT
- authorized to remove or modify any copyright notices embedded in the
- MFP1 library files and the resultant linkage.
-
- To register your copy you MUST supply us with your name, mailing
- address, day-time phone number, your compiler type and version, and
- a check or money order for $25.00.
-
- Please send your registration information to:
-
- Pride Software Advancement Corporation
- 3575 N.W. 31st Avenue
- Oakland Park, Florida
- 33309
-
- Your check or money order must be made payable to Pride Software
- Advancement Corporation.
-
- You may consider yourself licensed on the date you register this
- copy.
-
- Source code is available directly from Pride for $159.00 plus 6% tax.
- Include payment along with your registration if you want source and book.
-
- Software that you write and compile using the MFP1 library may be
- sold or given away without any additional license or fees.
-
- LIMITED WARRANTY
-
- We at Pride have made every effort to provide you with a bug-free and
- well designed product. All features have been extensively tested.
- We feel we are providing you with a mature and stable product. Nonetheless,
- we cannot be held liable for any loss of profit or any other commercial
- damage, including but not limited to, special; incidental; consequential;
- or other damages. You, as the developer, are the ultimate responsibilty for
- the integrity of your product.
-
- In the event that you discover a bug in the MFP1 library, you are re-
- quested to contact our programming staff at (305)731-1085. They shall
- make every effort to resolve your particular problem.
-
- GOVERNING LAW
-
- This statement shall be governed, interpreted, and construed by the laws
- of the State of Florida.
-
- INSTALLATION
-
- Installation is fairly straightforward, each library disk contains
- all the libraries and header files for that type compiler. Each library
- is named with its memory model as its suffix. There is only one header
- file beacuse it is not memory model dependent.
-
- The mfp.h header file should be copied into the directory where your
- other header files are stored.
-
- The MFPX.LIB files should be copied into the directory where you have
- your other library files stored.
-
- These are the only files you need to use MFP1. The other diskettes
- contain the source and object files necesarry to modify MFP1.
-
- Model Turbo C Lattice Microsoft
- ----- ------- ------- ---------
- Tiny T N/A T
- Small S S S
- Compact C P C
- Medium M D M
- Large L L L
- Huge H N/A H
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DATA ENTRY AND USER INPUT FUNCTIONS
-
- ===============================================================================
-
- MFP
-
- ===============================================================================
-
- Function Multiple Field Processor.
-
- Syntax void mfp( MFP *list, [ PROC *p_list ]|[ 0 ] );
-
- Prototype in mfp.h
-
- Remarks MFP scans the provided edit list to process a data
- entry session. The order in which the list is layed
- out is the order of field sequencing. Each field is
- entered and processed individually so any combination
- of character and numeric fields are permitted. Pre
- and post field validation is possible by providing
- the address of pre and post functions when defining
- an entry field.
-
- The pre and post validation functions can perform any
- task the programmer wishes. Pre and post validation tasks
- have access to all the variables concerning the data, its
- location, picture, and color.
-
- Character fields can be formatted by use of the picture
- formatting string. Numeric fields are defined in length,
- decimal places, and type using the same formatting struct-
- ure as printf().
-
- An optional procedure list can be passed which defines
- any key or group of keys as "HOT KEYS" that can execute
- any function you desire. A PROC list is created by you
- that associates any key with any function.
-
- NOTE: Microsoft and Lattice C users, because MFP uses its own
- color driver instead of relying on the graphics library
- functions, to optimize performance and resultant code size,
- the color driver MUST be disabled before exiting to DOS.
- This is performed by calling color() and passing it minus
- one in the fg and bg parameters, color( -1,-1 ).
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 7
-
- mfp
- MFP FIELD DEFINITION
-
- An MFP field is defined in the following manner:
-
- 1) A pointer to the data item.
- 2) A pointer to the picture format string.
- 3) The row and column of where the item will be on the screen.
- 4) The foreground and background attributes of the input field.
- 5) Optional pointers to the pre and post validation functions.
- If pre and post validation is not used, a zero must be placed
- in the pre and post validation positions.
-
- The following example will allow the entry of a three character string
- converted to uppercase at row 5 column 15 with a black foreground and a
- white background without pre or post validation. The field name is
- "example_1" and will be referenced by that name in the MFP list.
-
- char buffer[ 4 ];
- MFP example_1[] = { buffer, "!!!", 5, 15, BLACK, WHITE, 0, 0 };
- ^ ^ ^ ^ ^ ^ ^ ^ ^
- Field Name -------+ | | | | | | | |
- Pointer to data variable --------+ | | | | | | |
- Picture formatting string ---------------+ | | | | | |
- Row of field location ------------------------+ | | | | |
- Column of field location -------------------------+ | | | |
- Foreground color of entry field -----------------------+ | | |
- Background color of entry field ------------------------------+ | |
- Pre validation function pointer -----------------------------------+ |
- Post validation function pointer -------------------------------------+
-
- The following example will allow the entry of a five digit decimal integer
- at row 10 column 15 with a blue foreground and a black background. Post
- validation is performed but no pre validation.
-
- The field name is "example_2" and will be referenced by that name in the
- MFP list.
-
- void post(void);
- int idata;
- MFP example_2[] = { &idata, "%5d", 10, 15, BLUE, BLACK, 0, post };
-
- The following example will allow the entry of a twelve digit double
- precision floating point variable with nine digits left of
- the decimal point and two digits to the right. Including the
- decimal point, that makes up the field length of twelve. The
- input field will be located at row 15 column 15 and have a
- white foreground and blue background. Pre and post validation
- is performed.
-
- The field name is "example_3" and will be referenced by that name in the
- MFP list.
-
- void pre(void);
- void post(void);
- double fdata;
- MFP example_3[] = { &fdata, "%12.2lf", 15, 15, WHITE, BLUE, pre, post };
-
-
- 8
-
- mfp
- THE MFP LIST
-
- The MFP list array defines which fields are to be entered
- and in what order. The fields in the MFP list must be defined.
-
- The MFP list is the first parameter that will be passed to the mfp()
- function.
-
- The following example MFP list defines three fields to be inputted.
- The three fields were described on the previous pages of this text.
-
- MFP *example[] = { example_1, example_2, example_3, 0 };
-
- The MFP list "example" will tell the mfp() function that fields
- example_1, example_2, and example_3 are to be input and in the order
- that they appear in the list. When the mfp() function has scanned
- and processed all of the defined fields and has read in the zero
- it will exit and return control to the calling program.
-
- NOTE: All MFP lists must be terminated with a zero to define the end
- of the list.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 9
-
- mfp
- DATA ENTRY PICTURE FORMATTING
-
- One of the main features that makes MFP stand out is it's
- picture or data formatting capability. MFP uses a picture
- string to identify the data type and it's characteristics.
- Numeric variables are identified with a "%" percent symbol
- as the first picture character. Any other symbol in the first
- character position forces MFP to assume the data is a character
- array. Numeric data is always entered as BASE 10 or decimal.
-
- Character entry is filtered by MFP to not allow control codes into
- an entry field.
-
- Character formatting symbols are as follows:
-
- ! Upper case conversion. ( alphanumeric )
- * Security echo. All characters are allowed.
- 0 - 9 Numeric characters only, value limited by formatter
- A, a Alpha only allowed
- H, h Hexadecimal characters only
- X, x Any ASCII character
- Y, y Y or N only
- All others used as stationary objects
-
- Numeric formatting requirements are as follows:
-
- "%nn[.][nn]|[L][l][h]|[d][u][f]"
-
- * The first character must be a percent symbol.
- * A length parameter must be provided. This will represent
- the entire entry field length including decimal points and sign.
- * If a decimal point is provided a decimal length parameter is
- required to indicate the number of decimal positions. A decimal
- point cannot be used for non-floating point variables.
-
- NOTE: The length parameter must be at least three greater than
- the decimal length. ie; "%5.3f" would be illegal, yet "%5.2f"
- would be okay.
-
- * Last is the variable type. MFP allows certain modifiers to the
- standard variable types. The legal types are as follows:
-
- hd -- Short integer.
- d -- Signed integer.
- ld -- Signed long integer.
- u -- Unsigned integer.
- lu -- Unsigned long integer.
- f -- Single precision floating point.
- lf -- Double precision floating point.
- * Lf -- Long double precision floating point.
-
- * Long double is not a standard variable type. Turbo C supports long
- double along with a few other compilers. The other versions of this
- library converts your long double to a double. If your compiler
- supports long double, you may recompile the mfp.c file after changing
- the define LONGDOUBLE to equate to TRUE. Then you may replace the MFP
- object file in the library.
-
- 10
-
- mfp
- DATA ENTRY PICTURE FORMATTING (cont'd)
-
- The following are examples of numeric data entry pictures and the
- data they may represent:
-
- "%12.2lf" -- 999999999.99
- "%5d" -- 32565
- "%10lu" -- 9999999999
- "%7.4f" -- 99.9999
-
- The following are examples of character data entry pictures and
- the data they may represent:
-
- "(999)999-9999" -- Makes a good telephone field. The user can
- only enter or position the cursor at the
- non-stationary entry positions. The
- parenthesis and dashes would be skipped
- over allowing entry in only the proper
- fields. The "9"s allow any number from zero
- to nine to be entered.
-
- "!!!!!!!!!!" -- Ten characters all uppercase. Make sure the
- data item can hold ten characters plus a
- terminating NULL.
-
- "999-99-9999" -- Social security number entry field.
-
- "!!-999!!!!" -- The first two characters will be uppercase
- alphanumeric followed by a dash then three
- numeric only characters followed
- by four uppercase alphanumerics.
-
- "********" -- Eight character password entry field, all
- characters are allowed but only spaces are
- displayed.
-
- "99AAA!!!!" -- The first two characters are numeric the next
- three are alpha and the last four are uppercase
- alphnumeric.
-
- "Y" -- This is a single character entry field for
- a 'Y' or an 'N'. Input is converted to upper-
- case.
-
- "19/39/99" -- This is a character date entry field. The first
- character can be a '1' or '0'. The second can
- be any number, The third character is skipped
- but is part of the input string. The fourth
- character can be anything from '0' to '3'.
-
- "XXXXXXXX" -- This is an eight character entry field. No
- uppercase conversion is performed. What you
- type is what you get.
-
-
-
-
-
- 11
-
- mfp
- FIELD EDITING KEYS
-
-
- Up Arrow -- Moves cursor to first character of previous field.
-
- If already at the first field, moves cursor to beginning
- of field.
-
- Down Arrow -- Moves cursor to first character of next field.
-
- If aleady at last field, exits the editing session and
- mfp() returns to calling routine.
-
- Left Arrow -- Moves the cursor left to an input position in the
- current field.
-
- Will jump over non-input positions defined in the
- field picture.
-
- Has no effect if already at the first input character.
-
- Right Arrow -- Moves the cursor right to an input position in the
- current field.
-
- Will jump over non-input positions defined in the
- field picture.
-
- Has no effect if already at the last input position.
-
- Ctrl Right -- Moves the cursor to the last input position in the
- current field.
-
- Ctrl Left -- Moves the cursor to the first input position in the
- current field.
-
- Backspace -- Move cursor to next left input position while deleting
- the contents of the input position. Destructive backspace.
-
- Home -- Moves the cursor to the first input position of the first
- field.
-
- End -- Ends the edit session. mfp() returns to the calling
- function.
-
- Insert -- Puts mfp() into the insert mode allowing characters
- that are keyed to be inserted in front of characters
- that are positioned to the right. This key is a toggle
- which activates and deactivates the insert mode.
-
- Delete -- Deletes the current character and shifts all characters
- to the right of the deleted character left once.
-
- Ctrl Backspace -- Deletes the entire entry field and positions cursor to
- the beginning of the field.
-
-
-
-
- 12
-
- mfp
- PRE AND POST VALIDATION
-
- 1) Cursor moves into field.
- 2) Previous contents of field are displayed.
- 3) Jump to line 6 if no pre-process.
- 4) Procedure for pre-process is executed.
- 5) Jump to line 10 if pre-process returned valid as a FALSE.
- 6) User inputs data into field.
- 7) Jump to line 10 if no post-process.
- 8) Procedure for post-process is executed.
- 9) Skip to line 6 if post-process returned valid as a FALSE.
- 10) This field is finished, onto the next field...
-
- This describes the decisions mfp() makes when working a field. The
- field processor provides the pre and post validation functions a variety
- of data about the current field. Since the data is global, the pre and
- post validation functions you write can have access to all data in
- all fields allowing a great degree of flexibilty. The mfp() function
- will allow you to perform any type of operation you choose, including
- modifying the field you are entering or other fields.
-
- MFP provides the following list of global variables for your validation
- functions to use:
-
- int mfp_valid -- This variable is used to determine the outcome of your
- pre or post validation. If the validation fails this
- variable must be made FALSE. If your validation passes
- then make it TRUE.
-
- int mfp_field -- This variable represents the current field number
- starting with zero.
-
- int mfp_update -- This variable indicates if the fields contents have
- been changed. Non-zero if changed, zero if not changed.
-
- void *mfp_data -- This variable is a pointer to the data item being
- entered. Your validation function may use this any
- way you see fit. You may change the data items value
- or read it directly by using it.
-
- char *mfp_picture -- This is a pointer to the picture formatting string
- for the field being entered. You may use it any
- way you see fit.
-
- int mfp_row -- This variable provides your validation function with
- the screen row the entry field is on.
-
- int mfp_col -- This variable provides your validation function with
- the screen column the entry field is on.
-
- int mfp_fg -- This variable provides your validation function with
- the foreground color of the entry field.
-
- int mfp_bg -- This variable provides your validation function with
- the background color of the entry field.
-
-
-
- 13
-
- mfp
- THE PROCEDURE LIST
-
- The second parameter that can be passed to the MFP function is a
- procedure list that sets up a relationship of keyboard keys to
- functions.
-
- The procedure is called when the defined key is pressed. When the
- procedure is finished MFP regains control from where it left off.
-
- The typedef PROC defines a structure that is used to define the
- link between key and function. A PROC variable is defined and a
- list of PROC variables is passed to the MFP function.
-
- The PROC variable needs the integer key value returned by inkey()
- and a pointer to the function.
-
- Any key that the inkey() function can detect is legal for use
- as a hot key.
-
- The following is an example of hot key definitions:
-
- void help( void );
- void popup_1( void );
- void popup_2( void );
-
- PROC hotkey_1[] = { FN1, help }; /* F1 is for help */
- PROC hotkey_2[] = { FN2, popup_1 }; /* F2 is a popup menu */
- PROC hotkey_3[] = { FN3, popup_2 }; /* F3 is another popup */
-
- PROC *hotkeys[] = { hotkey_1, hotkey_2, hotkey_3, 0 };
-
- The PROC list "hotkeys" is an array of pointers to variables of type PROC.
-
- The order in which the hot keys are listed does not affect operation.
-
- The "hotkeys" variable would be passed as the second parameter in the
- mfp() function call. Any time F1, F2, or F3 were pressed when mfp() was
- executed the functions help(), popup_1(), or popup_2() would execute
- then return control to mfp().
-
- NOTE: The PROC list, like the MFP list, must be terminated with a
- zero.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 14
-
-
- MFP EXAMPLE LISTING mfp
-
- 1: #include <stdio.h>
- 2: #include <string.h>
- 3: #include <dos.h>
- 4: #include <conio.h>
- 5: #include <ctype.h>
- 6: #include <mfp.h>
- 7:
- 8: void drawscrn( char * );
- 9: void prompts( void );
- 10: void mess24( char *mess );
- 11: void help( void );
- 12: void inst( void );
- 13:
- 14: char name[ 21 ];
- 15: short int binarys = 0;
- 16: int rel_lum = 0;
- 17: long int sfc_temp = 0L;
- 18: unsigned int abs_lum = 0;
- 19: unsigned long int age_yrs = 0L;
- 20: float magnitd = 0.0;
- 21: double distance = 0.0;
- 22: long double mass = 0.0;
- 23:
- 24: MFP ln1[] = { name,"!!!!!!!!!!!!!!!!!!!!", 5,20,BLACK,WHITE,inst,0 };
- 25: MFP ln2[] = { &binarys, "%2hd", 7,20,BLACK,WHITE,inst,0 };
- 26: MFP ln3[] = { &rel_lum, "%6d", 9,20,BLACK,WHITE,inst,0 };
- 27: MFP ln4[] = { &abs_lum, "%6u", 11,20,BLACK,WHITE,inst,0 };
- 28: MFP ln5[] = { &sfc_temp, "%9ld", 13,20,BLACK,WHITE,inst,0 };
- 29: MFP ln6[] = { &age_yrs, "%9lu", 15,20,BLACK,WHITE,inst,0 };
- 30: MFP ln7[] = { &magnitd, "%9.3f", 17,20,BLACK,WHITE,inst,0 };
- 31: MFP ln8[] = { &distance, "%13.3lf", 19,20,BLACK,WHITE,inst,0 };
- 32: MFP ln9[] = { &mass, "%20.3Lf", 21,20,BLACK,WHITE,inst,0 };
- 33:
- 34: MFP *lst[] = { ln1, ln2, ln3, ln4, ln5, ln6, ln7, ln8, ln9, 0 };
- 35:
- 36: PROC p1[] = { FN1, help };
- 37: PROC p2[] = { FN2, fast };
- 38:
- 39: PROC *plist[] = { p1, p2, 0 };
- 40:
- 41: void main()
- 42: {
- 43: int yorn;
- 44: drawscrn("MFP Demonstration Program");
- 45: prompts();
- 46: do
- 47: {
- 48: mess24("Please enter above data...");
- 49: ed_list = lst;
- 50: mfp( lst, plist );
- 51: mess24("[ OPTIONS ] <E>dit, <S>ave, or <A>bort (E/S/A) ");
- 52: do
- 53: {
- 54: yorn = inkey();
- 55: }
- 56: while( !yorn );
- 15
-
-
- MFP EXAMPLE LISTING (cont'd) mfp
-
- 57: yorn = toupper( yorn );
- 58: if( yorn == 'S' )
- 59: {
- 60: mess24("Saving data...");
- 61: }
- 62: }
- 63: while( yorn == 'E' );
- 64: color( WHITE, BLACK );
- 65: }
- 66:
- 67: void drawscrn( char *header )
- 68: {
- 69: char buf[ 11 ];
- 70: int x;
- 71: color( WHITE, BLACK );
- 72: clrscr();
- 73: color( BLACK, WHITE );
- 74: wcls( 1,1, 2,80 );
- 75: color( WHITE, BLACK );
- 76: for( x = 3 ; x < 25 ; x++ )
- 77: {
- 78: cup( x,1 );
- 79: putch(186);
- 80: cup( x,48 );
- 81: putch(179);
- 82: cup( x,80 );
- 83: putch(186);
- 84: }
- 85: color( BLACK, WHITE );
- 86: wcls( 24,1, 24,80 );
- 87: cup( 1, 2 );
- 88: print( ldate( buf ) );
- 89: cup( 1,71 );
- 90: print( strtime( buf ) );
- 91: x = strlen( header );
- 92: cup( 2, (80-x)/2 );
- 93: print(header);
- 94: color( WHITE, BLACK );
- 95: wcls( 25,1, 25,80 );
- 96: cup( 25,2 );
- 97: print("F1 Help | F2 Jump | F3 | F4 | ");
- 98: print("F5 | F6 | F7 | F8 ");
- 99: }
- 100:
- 101: void prompts( void )
- 102: {
- 103: color( CYAN, BLACK );
- 104: cup( 5,4 );
- 105: print("Stellar Ident:");
- 106: cup( 7,4 );
- 107: print(" System Size:");
- 108: cup( 9,4);
- 109: print(" Relative Lux:");
- 110: cup( 11,4 );
- 111: print(" Absolute Lux:");
-
- 16
-
-
- MFP EXAMPLE LISTING (cont'd) mfp
-
- 112: cup( 13,4 );
- 113: print(" Surface Temp:");
- 114: cup( 15,4 );
- 115: print(" Stellar Age:");
- 116: cup( 17,4 );
- 117: print(" Magnitude:");
- 118: cup( 19,4 );
- 119: print(" Light Years:");
- 120: cup( 21,4 );
- 121: print(" Mass:");
- 122: color( WHITE, BLACK );
- 123: }
- 124:
- 125: void mess24( char *mess )
- 126: {
- 127: color( BLACK, WHITE );
- 128: wcls( 24,2,24,76 );
- 129: cup( 24,2 );
- 130: print( mess );
- 131: }
- 132:
- 133: char *name_txt[] = { "Please enter the name",
- 134: "of the stellar system.",
- 135: "",
- 136: "The name can be any",
- 137: "combination of letters",
- 138: "or numbers up to twenty",
- 139: "characters long.",
- 140: 0
- 141: };
- 142: char *size_txt[] = { "Please enter the number",
- 143: "of stellar mass bodies",
- 144: "in this system.",
- 145: "",
- 146: "A binary system would",
- 147: "have two stellar masses.",
- 148: "",
- 149: "A system like our sun's",
- 150: "would have only one.",
- 151: 0
- 152: };
- 153: char *lux_txt[] = { "Please enter the relative",
- 154: "intensity of the stellar",
- 155: "system in units of lux.",
- 156: "",
- 157: "This must be the relative",
- 158: "value not the absolute.",
- 159: "",
- 160: "This value may be positive",
- 161: "or negative with limits to",
- 162: "+/- 32000.",
- 163: "",
- 164: "It also must be a whole",
- 165: "number.",
- 166: 0
- 167: };
- 17
-
-
- MFP EXAMPLE LISTING (cont'd) mfp
-
- 168: char *alux_txt[] = { "Please enter the absolute",
- 169: "intensity of the stellar",
- 170: "system in units of lux.",
- 171: "",
- 172: "This must be the absolute",
- 173: "value and not the relative.",
- 174: "",
- 175: "This value must be positive.",
- 176: "Largest value cannot exceed",
- 177: "65,535. It must also be a",
- 178: "whole number.",
- 179: 0
- 180: };
- 181: char *sftp_txt[] = { "Please enter the surface",
- 182: "temparature in degrees",
- 183: "Kelvin.",
- 184: "",
- 185: "The measured temparature",
- 186: "must be in whole degrees",
- 187: "and may be positive or",
- 188: "negative.",
- 189: "",
- 190: "In the case of a multiple",
- 191: "unit system, please enter",
- 192: "the average temparature.",
- 193: 0
- 194: };
- 195: char *age_txt[] = { "Please enter the age of",
- 196: "the system in years.",
- 197: "",
- 198: "The age can be approximated",
- 199: "by the apparent luminosity",
- 200: "and the surface temp.",
- 201: "",
- 202: "The age cannot exceed 32",
- 203: "billion years.",
- 204: 0
- 205: };
- 206: char *magn_txt[] = { "Please enter the magnitude",
- 207: "of the largest body in this",
- 208: "system.",
- 209: "",
- 210: "The magnitude of this system",
- 211: "can be entered as a floating",
- 212: "point value.",
- 213: 0
- 214: };
- 215: char *ltyr_txt[] = { "Please enter the distance",
- 216: "from gravitaional center of",
- 217: "our solar system to the",
- 218: "gravitational center of",
- 219: "this system.",
- 220: "",
-
-
-
- 18
-
-
- MFP EXAMPLE LISTING (cont'd) mfp
-
- 221: "This value must be entered",
- 222: "in light years. Fractional",
- 223: "light years are permitted.",
- 224: 0
- 225: };
- 226: char *mass_txt[] = { "Please enter the systems",
- 227: "total mass in grams.",
- 228: "",
- 229: "This includes all masses",
- 230: "that rotate around the",
- 231: "center of mass of this",
- 232: "system.",
- 233: "",
- 234: "Planetary bodies can be",
- 235: "ommitted if no data is",
- 236: "present.",
- 237: 0
- 238: };
- 239: char **help_txt[] = { name_txt,
- 240: size_txt,
- 241: lux_txt,
- 242: alux_txt,
- 243: sftp_txt,
- 244: age_txt,
- 245: magn_txt,
- 246: ltyr_txt,
- 247: mass_txt
- 248: };
- 249:
- 250: void inst( void )
- 251: {
- 252: int x = 0;
- 253: color( WHITE, BLACK );
- 254: wcls( 5,50, 21,79 );
- 255: while( help_txt[ mfp_field ][ x ] )
- 256: {
- 257: cup( 7+x,50 );
- 258: print( help_txt[ mfp_field ][ x++ ] );
- 259: }
- 260: }
- 261:
- 262: void help( void )
- 263: {
- 264: char buf[ 4096 ];
- 265: scrswp( buf, 0 );
- 266: color( BLACK, WHITE );
- 267: wcls( 24,1,25,80 );
- 268: mess24("Your outta luck: no help available, press any key...");
- 269: pause();
- 270: scrswp( buf, 1 );
- 271: }
-
-
-
-
-
- 19
-
-
- MFP EXAMPLE LISTING NARRATIVE mfp
-
-
-
-
- Lines 1 - 5:
-
- Includes for the prototypes and defines for the standard C functions
- used.
-
- Line 6:
-
- Include file needed to use MFP.
-
- Lines 8 - 12:
-
- Prototypes of the functions used in this example.
-
- Lines 14 - 22:
-
- Definition and intialization of variables to be used for data entry.
- This definition must preceed the MFP field definitions.
-
- Lines 24 - 32:
-
- An MFP entry field must be defined in this manner: MFP is a typedef
- and must preceed the MFP entry field variable, in this case the
- entry field variable would be ln1. The entry field variable must be
- an array defined with an open and close bracket. The entry field
- variable is initialized using the equal sign and enclosing the entry
- field parameters within braces. A semicolon must terminate each field
- definition.
-
- Line 24:
-
- Definition of a 20 character entry field for the name array. The entry
- data will be upper case and be positioned at row 5 column 20. It will
- have a black foreground and a white background. There is a prevalidation
- function called inst(). No post validation has been defined.
-
- Line 25:
-
- Definition of a 2 digit short integer entry field for the short integer
- binarys variable. Notice the ampersand, (&) preceeding the binarys
- variable name. This is absolutely neccessary because MFP needs a pointer
- to the data. This is not the case with character arrays because the name
- alone is the pointer. So all numeric variables must be preceeded with
- the ampersand in the MFP declaration. The picture uses the same format
- as printf(). This is the case for all numeric entry fields.
-
- Lines 26 - 32:
-
- Differ in the variable type and entry field size. These examples
- represent all the variable types MFP can deal with. The entry field
- length, decimal points, screen position and color are defined by you.
-
-
-
- 20
-
-
- MFP EXAMPLE LISTING NARRATIVE (cont'd) mfp
-
-
- Line 34:
-
- Definition of the MFP list. The definition of this variable is
- straightforward enough. MFP needs a list of pointers to each entry
- field. The pointer to an entry field is its name without the array
- brackets. This variable happens to be called "lst". MFP will allow input
- into each field defined in "lst" and in the order that you put each entry
- field into lst. You can put whatever entry fields you want in whatever
- order you desire. The entry field must be defined prior to defining the
- list.
-
- -- All MFP lists must be terminated with a zero --
-
- All entry fields must be seperated by commas inside the MFP list.
- The list variable must be defined as an array of pointers to variables
- of type MFP. That is why lst is prefixed by an asterick and suffixed
- by an open and close bracket. This list variable called lst will be
- passed to MFP as it's first parameter.
-
- Line 36:
-
- Definition of a HOT key procedure. PROC is a typedef needed to define
- a procedure variable, in this case p1. The PROC variable must be
- declared as an array with an open and close bracket. The PROC variable
- is initialized using the same technique as MFP. The first parameter
- must be the keyboard key that will activate this PROC.
-
- Many of the keyboard keys have been defined for clarity. Any key that
- the inkey() function can sense is legal for a PROC. The inkey() function
- is used by MFP for all keyboard I/O this is why the PROC must use the
- value of the key returned by inkey(). In this example the FN1 definition
- evaluates to Function key 1 or "F1".
-
- The second parameter seperated by a comma is a pointer to the function
- that will execute when the key is pressed. A pointer to any function
- is its name without the open and close parenthesis. In this example
- a pointer to the function help() is used. The function must have been
- previously prototyped. In this example help() was prototyped in line 11.
-
- Line 37:
-
- HOT key PROC definition that sets up function key 2 to execute a
- function called fast(). The function fast() is a special function
- defined and programmed in the MFP library. It is prototyped in the mfp.h
- header. The fast() function places numbers in each entry field and
- prompts the user for which entry field they want to edit. When the user
- keys in the field number they are positioned into that field and are
- allowed to edit the data in that field. When they are finished editing,
- the fast() function terminates and the user is positioned back to the
- field they were previously editing. We suggest that you incorporate this
- feature into your applications - especially in screens with a large
- number of entry fields. If a user makes a mistake in a previous field or
- just wants to change one field's contents, the fast() function will be
- easier than moving up or down to the field to be changed.
-
- 21
-
-
- MFP EXAMPLE LISTING NARRATIVE (cont'd) mfp
-
-
-
-
- These HOT key PROC's only execute when mfp(), menu(), or scrn() are
- active. This should present little-to-no difficulty since most of the
- time your programs will be executing these functions awaiting user input.
-
- Line 39:
-
- Definition of the PROC list needed by MFP. This list which is called
- plist must be passed as the second parameter to MFP or scrn(). The PROC
- list must be defined in the same manner as the MFP list. It also must
- be terminated with a zero, to define the end of the list.
-
- Line 44:
-
- Calls the function to draw the screen and the screen header is passed
- as it's parameter.
-
- Line 45:
-
- Calls the function that displays the field prompts.
-
- Line 48:
-
- Calls the function to display the passed text on row 24.
-
- Line 49:
-
- Defines a global variable called "ed_list" to point to the MFP list,
- lst. The ed_list variable is the same variable type as the MFP list
- except it is used for the fast() function. If you are going to use the
- fast() function and you are including it into your PROC list you must
- define the ed_list variable. Most of the time you will define it as the
- same list as your MFP list. Sometimes you may want to define it as ano-
- ther list, to exclude or include other fields that are, or are not, acc-
- essable otherwise. The ed_list variable is initialized in the MFP library
- as pointing to nothing or NULL. If you find that the fast() function is
- doing nothing, check your ed_list definition. It must be defined before
- calling mfp().
-
- Line 50:
-
- This is the magic moment, here we call MFP. The parameters are lst
- and plist. By now we know what these parameters are and how they are
- defined. At this time the fields are displayed and the user is capable
- of performing data entry. When the user exits the last field or ends
- the edit session, mfp() returns.
-
- Line 51:
-
- Display to the user the available options on row 24.
-
-
-
-
- 22
-
-
- MFP EXAMPLE LISTING NARRATIVE (cont'd) mfp
-
-
-
- Lines 52 - 56:
-
- Await a response from the user. The inkey() function operates exactly
- like BASIC's INKEY statement. It tests the keyboard buffer for a charac-
- ter, if none exists it returns with a NULL. Otherwise, it returns with
- an integer value representing the key pressed. So we wait as long as no
- key is pressed.
-
- Line 57:
-
- Converts the key to it's uppercase equivalent.
-
- Lines 58 - 63:
-
- Determine the course of action to be taken based upon the key pressed.
- If the user responds by pressing the 'e' or 'E' key the user will be
- looped back into another edit session.
-
- Line 64:
-
- Sets the color to a white foreground and a black background in prepar-
- ation of exiting to DOS.
-
- Line 67:
-
- This is the function header for a draw screen function. The parameter
- header is used for the screen header.
-
- Line 72:
-
- Calls the clear screen function clrscr().
-
- Line 74:
-
- Calls the window or block clear screen. The function wcls() will clear
- a rectangular area of screen defined by upper left and lower right co-
- ordinates.
-
- Lines 76 - 85:
-
- Draws three vertical lines. The cup() function is used for <CU>rsor
- <P>ositioning. The row parameter is first followed by the column. The
- top left position would be cup( 1,1 ).
-
- Line 88:
-
- Displays the date in the upper left of the screen. The ldate() function
- is used which returns a pointer to the character array supplied. This
- array is stuffed with the current date retrieved from DOS.
-
- Line 90:
-
- Displays the time in the same manner as the date was displayed.
-
- 23
-
-
- MFP EXAMPLE LISTING NARRATIVE (cont'd) mfp
-
-
-
- Lines 100 - 123:
-
- This is the function that displays the prompts on the screen.
-
- Lines 125 - 131:
-
- Displays a message of text on row 24 of the screen.
-
- Lines 133 - 238:
-
- These are the help text strings, defined as an array of pointers for
- each field.
-
- Lines 239 - 248:
-
- Defines a single variable as a pointer to an array of pointers. The
- pointers are the help text. This simplifies coding of the online context
- sensitive help demonstrated here.
-
- Line 250:
-
- This is the function header for the inst() function that is the common
- prevalidation function used in all the entry fields.
-
- Line 252:
-
- Initializes and defines variable 'x'. This variable will be used to
- index through the lines of help text.
-
- Line 254:
-
- This clears the area of the screen right of the entry fields reserved
- for the help text.
-
- line 255:
-
- Determines if there is another line of text to be displayed for this
- field. It treats the help_txt variable as a two dimensional array. When
- the array points to a zero value it indicates that we are at the end of
- the help text for this field. The first array dimension is indexed by
- the mfp_field variable which indicates what field number we are at any
- given point. The second dimension indexes which line of text is being
- referenced.
-
- Line 258:
-
- Displays the line of text pointed to by the two dimensional pointer,
- help_txt. The 'x' indexer is post incremented to point to the next line.
-
- Lines 255 - 258:
-
- Loop until a zero value is resolved. This zero is stored at the end of
- each field help string set.
-
- 24
-
-
- MFP RUN TIME ERROR MESSAGES
-
- MFP generates very few run time messages, mostly because of its
- structure. The error checking that MFP does perform is mostly limited
- to the mfp() function itself and primarily only to picture formatting
- and input field declaration. MFP will not generate field overflow or
- other like messages - it is only concerned about your definitions, which
- are hard-coded by you. Unless you write self-modifying code, you should
- not expect messages from MFP. If you do get messages from MFP and you
- know that your declarations are correct, be on the lookout for ill-
- behaved memory usage. For instance, when you clear an array's contents
- make sure you are remaining within its boundries, if you go beyond, you
- will be destroying possible string space or even worse, the program itself.
-
- *ERROR* Picture Format Invalid -> <your format here>
-
- This error is generated when mfp is extracting the variable type
- out of your picture string. No match was found for the nine data
- types that mfp supports. Mfp expects the following data types and
- cannot understand any others - also watch out for upper and lower
- case. Any picture format that begins with a "%" symbol is assumed
- by mfp() to be a numeric and will be type checked as one and must
- have the following type identifiers at the end of the picture
- string : "ld","hd","d","lu","u","Lf","lf","f". If your picture
- string begins without the "%" symbol, mfp() will assume that the
- entry is a character string or array.
-
- *ERROR* Missing format length -> <your format here>
-
- This error is generated when mfp is setting up the input field
- length. This error occurs only on numeric entry fields. If you
- neglected to pass a length modifier in your picture format, you
- can expect to see this error message. Numeric entry picture strings
- MUST have a length modifier so mfp() can build an entry field of
- that size for your user to input the data. The mfp() function makes
- no assumptions about field length for any numeric type. A properly
- declared picture for a five digit unsigned long integer would look
- like "%5lu". Mfp uses the '5' to build an entry field five characters
- in length.
-
- *ERROR* Length too short -> <your format here>
-
- This error occurs only on floating point numeric entry with a
- decimal point involved in the picture. When mfp() gets the field
- length and the number of digits to the right of the decimal point,
- it checks to see if you have given enough room in the field length
- for the sign, decimal point itself, and one digit to the left. This
- means that mfp() needs at least a field length of three digits more
- than the number of digits to the right of the decimal. For example
- if you wanted to define a field for the entry of a floating point
- number that had four decimal digits to the right of the decimal,
- the minimum field length would be seven digits, "%7.4f". If you
- were to define a field as, "%10.8lf", mfp() would give you this
- error message because it couldn't build the field in ten digits and
- work properly. The proper definition would be, "%11.8lf" or "%10.7lf".
- The above examples are only minimums, you may exceed the minimums as
- your application demands, ie; "%12.2lf","%10.2Lf","%4.0f","%5f"...
-
- 25
-
- ===============================================================================
-
- MENU
-
- ===============================================================================
-
- Function User menu function with HOT key support.
-
- Syntax int menu( MENU **menulist, PROC **proclist )
-
- Prototype in mfp.h
-
- Remarks Returns an integer value representing the menu option selected.
- The return value would be from zero to N - 1. If the user
- presses the escape key, a value of -1 is returned.
-
- The menu() function presents to the user your menu and the help
- text if provided. The user knows which menu option he is at
- by menu() highlighting the current option. The user navigates
- through the menu list via the standard cursor keys. The user
- may also select an option by pressing the appropriate key,
- this immediatly selects the option with one keypress. The user
- may also press the escape key and menu() will return with a -1.
- When the user cursors over to the wanted selection, he must
- press enter to validate the selection and menu() returns with
- the integer value of his selection.
-
- The menu() function also supports HOT key PROC's. You must
- provide a PROC list, exactly as in mfp(). If the user presses
- a PROC key, the menu() function will execute the PROC and
- return back to the menu when completed.
-
- The menu() function requires a MENU list. This list is a
- group of menu items in the order of value you want returned.
- The first item of a menu list, if selected, will have a value
- of zero; the second item will have a value of one; and so-on
- for the rest. The MENU list MUST be terminated with a zero to
- identify the end of the list.
-
- The menu() function can accept a PROC list for HOT key PROC
- capability. If you don't wan't PROC key support you must
- pass a zero as the PROC parameter.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 26
-
- menu
-
- MENU ITEM DEFINITION:
-
- Each menu item is defined using the typedef MENU. This
- simplifies your coding and makes defining a menu a snap.
-
- An example menu item is defined as follows:
-
- MENU item1[] = { 10, 20, "Edit", 'E', "Edit the above data." };
-
- The typedef MENU is followed by an item name which must be
- unique. The item must be declared as an array. The array is
- to be defined by direct assignment using the equals symbol
- followed by an open brace.
-
- The first parameters in the braces are the row and column
- respectively. This is the row and column where this item will
- appear on the screen.
-
- The next parameter is the item text that will be displayed.
-
- Following the item text is the alternate keyboard key that
- can also be used to select this item. If this key is pressed,
- this item will be selected and menu() will return with this
- menu item's value. This parameter MUST be uppercase, because
- the keyboard input will be converted to uppercase for testing.
-
- Last but not least, is the optional help text that will be
- displayed when this menu item is highlighted. If you do not
- want any help text to be displayed, you must place a zero in
- this parameter.
-
- Finally the menu declaration must be terminated with a close
- brace and a semicolon.
-
- THE MENU LIST:
-
- The menu list directs menu() to show the menu items in the
- order you established in the list, the return value starting
- from zero indicates the selection the user made, the first item
- in the menu list being zero and the last; N - 1. The menu list
- MUST be terminated with a zero. The menu list must be declared
- with the typedef MENU as an array of pointers.
-
- MENU *menulist[] = { item1, item2, item3, 0 };
-
- THE MENU COLOR:
-
- The menu function defaults to a white on black menu with
- the highlighted selection being black on white. This can
- be altered by changing the value of the following global
- variables that menu() uses:
-
- MENNORMFG This is the normal menu foreground attribute.
- MENNORMBG This is the normal menu background attribute.
- MENLITEFG This is the highlighted foreground attribute.
- MENLITEBG This is the highlighted background attribute.
-
- 27
-
- menu
- THE HELP TEXT:
-
- The help text parameter is displayed when the user
- navigates to a menu item that has a help text line
- declared other than a zero. This text must not go beyond
- the 80th column. The help text line is cleared before
- the text is displayed so shorter lines won't appear with
- the remnents of a previous longer line.
-
- The help text is defaulted to be displayed on row 25
- column 1 with a WHITE on BLACK attribute with a maximum
- text length of 80 characters.
-
- The help text position and attributes can be changed by
- modifying the contents of the following global variables:
-
- MENHLPROW This is a global integer that is used for
- the row position of the menu help text.
-
- MENHLPCOL This global integer is used for the column
- position of the menu help text.
-
- MENHLPLEN This global integer is used to determine
- the maximum length of the help text. This,
- plus the MENHLPCOL, cannot extend past column
- 80 on the screen. MENHLPCOL + MENHLPLEN <= 80
-
- MENHLPFG This global integer is used for the foreground
- attribute of the help text color.
-
- MENHLPBG This global integer is used for the background
- attribute of the help text color.
-
- The above variables are declared in the mfp library and
- prototyped for you in mfp.h. To change one or more of the
- the above items you only need to assign the value with an
- assignment statement, ie;
- MENHLPROW = 2;
-
- This assignment changed the help text row to row 2. Any
- changes to these variables are global and remain until
- changed again.
-
-
- MENU INITIAL POSITIONING:
-
- The initial menu selection can be preset within the
- range of menu options present.
-
- MENSELPOS -- This is the global menu initial position
- variable. It is normally set to (-1), this
- makes the menu start at the top item. Any
- other value of 0 to n-1 will highlite the
- appropriate selection.
-
- The menu function does not modify the value of MENSELPOS.
- MENSELPOS is a signed integer.
-
- 28
-
- menu
-
- EXAMPLE:
-
-
- #include <stdio.h>
- #include <mfp.h>
-
- MENU item1[] = { 10,20, "1) Accounts receivable.", '1', 0 };
- MENU item2[] = { 12,20, "2) Accounts payable....", '2', 0 };
- MENU item3[] = { 14,20, "3) Payroll.............", '3', 0 };
- MENU item4[] = { 16,20, "4) General ledger......", '4', 0 };
- MENU item5[] = { 20,20, "Exit...................", 'Q',
- "Exit this program to DOS..." };
-
- MENU *mainmenu[] = {
- item1, item2, item3, item4, item5, 0
- };
-
-
- void main( void )
- {
- int menu_sel;
-
- do
- {
- clrscr();
-
- menu_sel = menu( mainmenu, 0 );
-
- switch( menu_sel )
- {
- case 0:
- accrecv();
- break;
- case 1:
- accpay();
- break;
- case 2:
- payroll();
- break;
- case 3:
- genldgr();
- break;
- default:
- break;
- }
-
- } while( menu_sel != 4 && menu_sel != -1 );
-
- return;
- }
-
-
-
-
-
-
-
- 29
-
- ===============================================================================
-
- PIC
-
- ===============================================================================
-
- Function Single line character entry with picture formatting.
-
- Syntax char *pic( char *data, char *picture )
-
- Prototype in mfp.h
-
- Remarks
-
- Pic() returns a pointer to the character string provided as
- the data parameter. It acts as a replacement for gets(),
- with all the line editing features of mfp(). A character
- picture string is required. Pic() terminates when the user
- presses the enter or escape key. Since the same keys are used
- for editing as in mfp(), pic is an ideal choice for single
- field entry.
-
- The escape key clears the input field and pic terminates.
-
- Pic() pads any trailing white space with NUL's upon termin-
- ation.
-
- The following is a list of picture characters:
-
- Format Character Purpose
-
- ! Upper case conversion ( allows numerics )
- * Security echo. All characters are allowed.
- 0 - 9 Numeric only, largest value filtered
- A, a Alpha only allowed
- H, h Hexadecimal Only
- X, x Any ASCII character
- Y, y Yes or No only
- All others used as stationary objects
-
- EXAMPLE:
- #include <stdio.h>
- #include <mfp.h>
-
- char *picture = "999-99-9999";
- char data[ 12 ];
-
- void main( void )
- {
- zero( data, 12 );
- clrscr(); /* Clear the screen */
- cup( 10, 15 );
- print("Please enter your social security number:");
- pic( data, picture );
- }
-
-
-
-
- 30
-
- ===============================================================================
-
- SCRN
-
- ===============================================================================
-
- Function Single line entry function with HOT key processing.
-
- Syntax int scrn( char *data, char *picture, PROC **proc_list )
-
- Prototype in mfp.h
-
- Remarks Scrn() is used in place of pic() when a single data item
- is to be entered - be it one character or an entire line.
-
- The major differences between scrn() and pic() are: pic()
- returns a character pointer to the edited data item and
- scrn() returns an integer representing the key press that
- terminated the edit session. Also, scrn() allows a procedure
- list as the third parameter for HOT key processing.
-
- If HOT key processing is not required you may pass a zero
- as the PROC parameter, otherwise you should pass a procedure,
- PROC list, exactly like that used in mfp().
-
- To clarify scrn() further, it should be mentioned here
- that scrn() is the actual editing function used by mfp().
-
- Scrn() uses the same picture format as pic().
-
- Scrn() terminates with the following key presses: enter, home,
- end, up arrow, down arrow, and escape.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 31
-
- ===============================================================================
-
- INKEY
-
- ===============================================================================
-
- Function Keyboard input without wait or echo.
-
- Syntax int inkey( void );
-
- Prototype in mfp.h
-
-
- Remarks Same as BASIC's INKEY$ statement. When called, it
- checks for the presence of a key press from the keyboard
- buffer. Returns an integer value representing the key
- pressed. Returns only one key press at a time. If
- no key presses are in the buffer, it returns a zero.
- Extended keys are returned with a 0x0F placed in the
- upper 8 bits. This simplifies dealing with extended
- scan codes from the keyboard.
-
-
-
- EXAMPLE:
-
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- unsigned int x = 0;
-
- while( x != 3 )
- {
- x = inkey();
-
- if( x )
- printf("%x\n",x);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 32
-
- inkey
- KEYBOARD USAGE:
-
- Inkey returns the following hexadecimal integer for each key combination.
- Shift, Control, and Alternate combinations are designated as S, C, or A.
-
-
- Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12
- +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------------+
- N| 1B|F3B|F3C|F3D|F3E| |F3F|F40|F41|F42| |F43|F44| | | |N
- S| 1B|F54|F55|F56|F57| |F58|F59|F5A|F5B| |F5C|F5D| | | |S
- C| 1B|F5E|F5F|F60|F61| |F62|F63|F64|F65| |F66|F67| | | |C
- A| |F68|F69|F6A|F6B| |F6C|F6D|F6E|F6F| |F70|F71| | | |A
- +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------------+
-
-
- ~/` !/1 @/2 #/3 $/4 %/5 ^/6 &/7 */8 (/9 )/0 _/- +/= BKS INS HOM PUP
- +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
- N| 60| 31| 32| 33| 34| 35| 36| 37| 38| 39| 30| 2D| 39| 8| |F52|F47|F49| |N
- S| 7E| 21| 40| 23| 24| 25| 5E| 26| 2A| 28| 29| 5F| 2B| 8| |F52|F47|F49| |S
- C| | |F03| | | | 1E| | | | | 1F| | 7F| | |F77|F84| |C
- A| |F78|F79|F7A|F7B|F7C|F7D|F7E|F7F|F80|F81|F82|F83| | | | | | |A
- +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-
-
- TAB Q W E R T Y U I O P {/[ }/] |/\ DEL END PDN
- +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
- N| 9| 71| 77| 65| 72| 74| 79| 75| 69| 6F| 70| 5B| 5D| 5C| |F53|F4F|F51| |N
- S|F0F| 51| 57| 45| 52| 54| 59| 55| 49| 4F| 50| 7B| 7D| 7C| |F53|F4F|F51| |S
- C| | 11| 17| 5| 12| 14| 19| 15| 9| F| 10| 1B| 1D| 1C| | |F75|F76| |C
- A| |F10|F11|F12|F13|F14|F15|F16|F17|F18|F19| | | | | | | | |A
- +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-
-
- CAP A S D F G H J K L :/; "/' ENTER
- +---+---+---+---+---+---+---+---+---+---+---+---+-------+-------------------+
- N| | 61| 73| 64| 66| 67| 68| 6A| 6B| 6C| 3B| 27| D | |N
- S| | 41| 53| 44| 46| 47| 48| 4A| 4B| 4C| 3A| 22| D | |S
- C| | 1| 13| 4| 6| 7| 8| A| B| C| | | A | |C
- A| |F1E|F1F|F20|F21|F22|F23|F24|F25|F26| | | | |A
- +---+---+---+---+---+---+---+---+---+---+---+---+-------+-------------------+
-
-
- SHIFT Z X C V B N M </, >/. ?// SHIFT UP
- +-------+---+---+---+---+---+---+---+---+---+---+-------+-------+---+-------+
- N| | 7A| 78| 63| 76| 62| 6E| 6D| 2C| 2E| 2F| | |F48| |N
- S| | 5A| 58| 43| 56| 42| 4E| 4D| 3C| 3E| 3F| | |F48| |S
- C| | 1A| 18| 3| 16| 2| E| D| | | | | | | |C
- A| |F2C|F2D|F2E|F2F|F30|F31|F32| | | | | | | |A
- +-------+---+---+---+---+---+---+---+---+---+---+-------+-------+---+-------+
-
-
- CTL ALT SPACE BAR ALT CTL LFT DWN RGT
- +---+---+---+-------------------------------+---+---+---+---+---+---+---+---+
- N| | | | 20 | | | | |F4B|F50|F4D| |N
- S| | | | 20 | | | | |F4B|F50|F4D| |S
- C| | | | 20 | | | | |F73| |F74| |C
- A| | | | 20 | | | | | | | | |A
- +---+---+---+-------------------------------+---+---+---+---+---+---+---+---+
- 33
-
- inkey
- DEFINITIONS FOR INKEY:
-
- The following is a list of definitions in mfp.h used for inkey(). Please feel
- free to use them in your programs to make your keyboard references clearer.
-
- FN1 Function key 1 UPARROW Up arrow
- FN2 Function key 2 DNARROW Down arrow
- FN3 Function key 3 LFARROW Left arrow
- FN4 Function key 4 RTARROW Right arrow
- FN5 Function key 5 C_LFARROW Control left arrow
- FN6 Function key 6 C_RTARROW Control right arrow
- FN7 Function key 7 INSERT Insert key
- FN8 Function key 8 DELETE Delete key
- FN9 Function key 9 HOME Home key
- FN10 Function key 10 END End key
- S_FN1 Shift function key 1 PAGEUP Page up key
- S_FN2 Shift function key 2 PAGEDN Page down key
- S_FN3 Shift function key 3 C_HOME Control home
- S_FN4 Shift function key 4 C_END Control end
- S_FN5 Shift function key 5 C_PAGEUP Control page up
- S_FN6 Shift function key 6 C_PAGEDN Control page down
- S_FN7 Shift function key 7 ESCAPE Escape key
- S_FN8 Shift function key 8 BACKSPACE Backspace key
- S_FN9 Shift function key 9 C_BACKSPACE Control backspace
- S_FN10 Shift function key 10 TAB Tab key
- C_FN1 Control function key 1 S_TAB Shift tab
- C_FN2 Control function key 2 ENTER Enter key
- C_FN3 Control function key 3 C_ENTER Control enter
- C_FN4 Control function key 4 C_MINUS Control minus
- C_FN5 Control function key 5 A_MINUS Alternate minus
- C_FN6 Control function key 6 A_EQUAL Aternate equal
- C_FN7 Control function key 7 TRUE Logical true (non zero)
- C_FN8 Control function key 8 FALSE Logical false (zero)
- C_FN9 Control function key 9 CTL_2 Control two
- C_FN10 Control function key 10 CTL_6 Control six
- A_FN1 Alternate function key 1 ALT_0 Alternate zero
- A_FN2 Alternate function key 2 ALT_1 Alternate one
- A_FN3 Alternate function key 3 ALT_2 Alternate two
- A_FN4 Alternate function key 4 ALT_3 Alternate three
- A_FN5 Alternate function key 5 ALT_4 Alternate four
- A_FN6 Alternate function key 6 ALT_5 Alternate five
- A_FN7 Alternate function key 7 ALT_6 Alternate six
- A_FN8 Alternate function key 8 ALT_7 Alternate seven
- A_FN9 Alternate function key 9 ALT_8 Alternate eight
- A_FN10 Alternate function key 10 ALT_9 Alternate nine
-
- CTL_A CTL_N ALT_A ALT_N CTL_B
- CTL_O ALT_B ALT_O CTL_C CTL_P
- ALT_C ALT_P CTL_D CTL_Q ALT_D
- ALT_Q CTL_E CTL_R ALT_E ALT_R
- CTL_F CTL_S ALT_F ALT_S CTL_G
- CTL_T ALT_G ALT_T CTL_H CTL_U
- ALT_H ALT_U CTL_I CTL_V ALT_I
- ALT_V CTL_J CTL_W ALT_J ALT_W
- CTL_K CTL_X ALT_K ALT_X CTL_L
- CTL_Y ALT_L ALT_Y CTL_M CTL_Z
- ALT_M ALT_Z
-
- 34
-
- ===============================================================================
-
- GETKEY
-
- ===============================================================================
-
- Function Single character input with echo.
-
- Syntax char getkey( void );
-
- Prototype in mfp.h
-
-
- Remarks Allows a single character to be inputted. All characters
- are converted to upper case.
-
-
- EXAMPLE:
-
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- char c = '\0';
-
- while( c != 'A' )
- {
- c = getkey();
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 35
-
- ===============================================================================
-
- FLUSH
-
- ===============================================================================
-
- Function To flush any characters in the keyboard buffer.
-
- Syntax void flush( void )
-
- Prototype in mfp.h
-
- Remarks Clears the typeahead of the keyboard. Handy before using
- the inkey() function. Assures that the next key pressed did
- not occur before you expected.
-
- EXAMPLE:
-
- #include <stdio.h>
- #include <mfp.h>
-
- void wait_usr( void )
- {
- cup( 24,2 );
- print("Press any key when ready...");
-
- flush();
-
- while( !inkey() )
- ;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 36
-
- ===============================================================================
-
- PAUSE
-
- ===============================================================================
-
- Function To suspend program operation until a key is pressed.
-
- Syntax void pause( void );
-
- Prototype in mfp.h
-
-
-
- Remarks Pause() waits until a keypress occurs before returning.
- It flushes the keyboard buffer before waiting for a keypress.
-
-
-
- EXAMPLE:
-
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- printf("Press any key to continue...");
-
- pause();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 37
-
- ===============================================================================
-
- FAST
-
- ===============================================================================
-
- Function Single line edit feature
-
- Syntax void fast( void )
-
- Prototype in mfp.h
-
-
- Remarks Allows editing of one user selected field from a supplied
- list of fields.
-
- Fast() is primarily designed to operate as a function key
- procedure used in a MFP edit session. It is assigned a
- function key within a PROC declaration.
-
- A global edit list called "ed_list" must be intialized.
-
- Fast() uses this "ed_list" to know the fields that can
- be edited. Commonly the ed_list is made equal to the
- mfp list that you pass to MFP. This allows fast() to
- access all fields on the screen.
-
- In some cases you may want certain fields excluded or
- extra fields included. You should set up a seperate edit
- list for these occasions.
-
- The ed_list is defined in the MFP library. This means
- you can make up several fast edit lists and before calling
- mfp() you can make "ed_list" equal to that list.
-
- In the example program described in the MFP section you
- will notice the fast() function being assigned to function
- key two. You should also notice that the "ed_list" is made
- equal to the mfp list in line 49. This makes all fields
- defined in that mfp list accessable to the fast() function.
-
- Any function that uses the PROC list for function key
- procedures may use fast() to allow field editing.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 38
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SCREEN OUTPUT FUNCTIONS
-
- ===============================================================================
-
- COLOR
-
- ===============================================================================
-
- Function Color attribute of character data on screen.
-
- Syntax void color( int foreground, int background );
-
- Prototype in mfp.h
-
- Remarks Subsequent character display will have the color
- attributes defined in the color statement. Can be
- used for monochrome or color monitors.
-
- *** FOREGROUND *** *** OUTPUT ***
- DEFINE VALUE COLOR MONITOR MONOCHROME MONITOR
-
- REMOVE -1 Disengage the color driver
- BLACK 0 black foreground black
- BLUE 1 blue white w/ underline
- GREEN 2 green white
- CYAN 3 cyan white
- RED 4 red white
- MAGENTA 5 magenta white
- BROWN 6 brown white
- LIGHTGRAY 7 white white
- DARKGRAY 8 gray black
- LIGHTBLUE 9 bright blue Bright white w/ underline
- LIGHTGREEN 10 " green " white
- LIGHTCYAN 11 " cyan " "
- LIGHTRED 12 " red " "
- LIGHTMAGENTA 13 " magenta " "
- YELLOW 14 " yellow " "
- WHITE 15 " white " "
-
- BLINK - Adding 16 to the above colors will cause blinking -
-
- *** BACKGROUND *** *** OUTPUT ***
- DEFINE VALUE COLOR MONITOR MONOCHROME MONITOR
-
- NONE -1 Do not change the background color
- BLACK 0 Black Backround Black
- BLUE 1 blue "
- GREEN 2 green "
- CYAN 3 cyan "
- RED 4 red "
- MAGENTA 5 magenta "
- BROWN 6 brown "
- WHITE 7 white White
-
- NOTE: With monochrome systems, a white background will always produce
- a black on white.
-
- WARNING: If you are not using Turbo C, you MUST disengage the color driver
- by passing a (-1) as the foreground attribute before exiting to
- DOS. Failure to do so may cause a lock-up due to the video vector,
- (10H), being corrupt.
- 40
-
- ===============================================================================
-
- CUP
-
- ===============================================================================
-
- Function Cursor Positioning
-
- Syntax void cup( int row, int column );
-
- Prototype in mfp.h
-
- Remarks The cup() function allows you to position the cursor anywhere
- on the screen. The row and column parameters begin at one and
- end at 25 and 80 repectively.
-
- EXAMPLE:
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- int row, col;
-
- /*
- Fill the screen with stars...
- */
-
- for( row = 1 ; row < 26 ; row++ )
- {
- for( col = 1 ; col < 81 ; col++ )
- {
- cup( row, col );
- bioputc('*');
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 41
-
- ===============================================================================
-
- GETCUP
-
- ===============================================================================
-
- Function Get Cursor Position
-
- Syntax unsigned getcup( void );
-
- Prototype in mfp.h
-
- Remarks The getcup() function returns the cursor position on the
- screen. The row is in the upper eight bits and the column
- in the lower eight bits. Row and column ranges from 1 to 25
- and 1 to 80 repectively.
-
- EXAMPLE:
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- int row, col;
- unsigned rowcol;
-
- rowcol = getcup();
-
- row = (rowcol >> 8) & 0xff;
- col = rowcol & 0x0ff;
-
- printf("Row %d, Col %d",row,col);
- }
-
-
-
-
-
- 42
-
- ===============================================================================
-
- PRINT
-
- ===============================================================================
-
- Function High performance unformatted character string display.
-
- Syntax void print( char * );
-
- Prototype in mfp.h
-
-
- Remarks Displays to the console any character array or string.
-
-
-
- EXAMPLE:
-
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- char *s = "Hello world!\n";
-
- print("Hello world!\n");
-
- print( s );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 43
-
- ===============================================================================
-
- SAY
-
- ===============================================================================
-
- Function High performance unformatted character string display with
- cursor coordinates.
-
- Syntax void say( int row, int col, char * );
-
- Prototype in mfp.h
-
-
- Remarks Displays to the console any character array or string at the
- desired row and column. This function is a convenient method
- of displaying string data. This function is a marraige of
- cup and print.
-
-
- EXAMPLE:
-
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- int r, c;
- char *s = "Hello world!\n";
-
- r = 10;
- c = 15;
-
- say( 10,15,"Hello world!\n" );
-
- say( r,c,s );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 44
-
- ===============================================================================
-
- BIOPUTC
-
- ===============================================================================
-
- Function High performance character display function.
-
- Syntax void bioputc( char c );
-
- Prototype in mfp.h
-
- Remarks For Lattice and Microsoft C users only.
-
- The Lattice and Microsoft libraries do not provide a high
- throughput character output function capable of providing
- adequate performance for MFP's needs. The bioputc() function
- is a putch() clone except it is twice as fast. This is because
- control-break checking is not performed.
-
- The bioptuc() function uses direct bios video services with
- attribute support so color will work. The MFP library uses the
- bioputc() function for all video output in the Lattice and
- Microsoft versions.
-
- TURBO C USERS: This function is not included in your library
- because you don't need it. The Turbo C library is very opti-
- mized and this function would only be redundant. The putch()
- function performs the same.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 45
-
- ===============================================================================
-
- ESHOW
-
- ===============================================================================
-
- Function Displays a defined mfp() entry screen.
-
- Syntax void eshow( MFP **mfp_list )
-
- Prototype in mfp.h
-
-
- Remarks The eshow() function displays the fields defined in
- the passed mfp list parameter. This is handy if you
- wish to display the field contents before allowing
- an edit session.
-
- The eshow() function requires the same type of MFP
- list that the mfp() function uses.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 46
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- WINDOWING FUNCTIONS
-
- ===============================================================================
-
- WINDOW_CREATE
-
- ===============================================================================
-
- Function Window creation
-
- Syntax WINDOW *window_create( unsigned ulr, unsigned ulc,
- unsigned lrr, unsigned lrc );
-
- Prototype in mfp.h
-
- Remarks Window_create() allocates memory using malloc() and
- copies the area defined in the parameter list to the
- allocated memory. If enough memory is available the
- function returns with a pointer to the window record.
-
- If an error occurs allocating memory for the window the
- function returns with a NULL value.
-
- The pointer to the window record is unique for each
- window and must be preserved until the window is killed.
-
- CAUTION Windows should be killed in the reverse order they were
- created. This will insure your memory pool's integrity.
-
-
- Example Usage:
-
-
- void errtypesel( unsigned r, unsigned c )
- {
- static WINDOW *erbuf;
-
- if( c > 40 )
- c -= 20;
-
- erbuf = window_create( r+5,c+10,r+10,c+29 );
- color( YELLOW,MAGENTA );
- wcls( r+5,c+10,r+10,c+29 );
- box( r+5,c+10,r+10,c+29,0 );
- color( LIGHTGREEN,MAGENTA );
- cup( r+6,c+12 );
- print("Disk type cannot");
- cup( r+7,c+12 );
- print("exceed master.");
- cup( r+9,c+12 );
- print("Press any key...");
- bioputc(7);
- pause();
- window_kill( erbuf );
- }
-
-
-
-
-
-
- 48
-
- ===============================================================================
-
- WINDOW_KILL
-
- ===============================================================================
-
- Function Window removal
-
- Syntax void window_kill( WINDOW *winrec );
-
- Prototype in mfp.h
-
- Remarks Window_kill() copies the screen data saved during
- the window_create() back to the screen. It also
- deallocates the memory used to store the screen data
- and the window record.
-
- CAUTION Windows should be killed in the reverse order they were
- created. This will insure your memory pool's integrity.
-
-
- Example Usage:
-
-
- void errtypesel( unsigned r, unsigned c )
- {
- static WINDOW *erbuf;
-
- if( c > 40 )
- c -= 20;
-
- erbuf = window_create( r+5,c+10,r+10,c+29 );
- color( YELLOW,MAGENTA );
- wcls( r+5,c+10,r+10,c+29 );
- box( r+5,c+10,r+10,c+29,0 );
- color( LIGHTGREEN,MAGENTA );
- cup( r+6,c+12 );
- print("Disk type cannot");
- cup( r+7,c+12 );
- print("exceed master.");
- cup( r+9,c+12 );
- print("Press any key...");
- bioputc(7);
- pause();
- window_kill( erbuf );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- 49
-
- ===============================================================================
-
- WCLS
-
- ===============================================================================
-
- Function Clear an area of the screen.
-
- Syntax void wcls(int u_l_row,int u_l_col, int l_r_row, int l_r_col);
-
- Prototype in mfp.h
-
-
- Remarks Clear an area defined by the upper left and lower right
- corners. Handy for simple windows or clearing screen
- sections.
-
-
- EXAMPLE:
-
-
- void main( void )
- {
- /*
- Clear a box at row 5 column 15 to row 10 column 30.
- */
-
- wcls( 5, 15, 10, 30 );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 50
-
- ===============================================================================
-
- BOX
-
- ===============================================================================
-
- Function Draw a rectangular box
-
- Syntax void box( int ulr, int ulc, int lrr, int lrc, int type );
-
- Prototype in mfp.h
-
- Remarks Outlines a box using the extended ASCII box drawing characters
- at the coordinates supplied.
-
- You must pass box() the upper left row, upper left column,
- lower right row, lower right column, and the box type.
-
- The box() function will outline four box types:
-
- 0 -- Single lines horizontal and vertical.
- 1 -- Double lines horizontal and vertical.
- 2 -- Double lines horizontal and single lines vertical.
- 3 -- Single lines horizontal and double lines vertical.
-
- EXAMPLE:
-
- #include <stdio.h>
- #include <mfp.h>
-
- #define SCREEN 0
- #define BUFFER !SCREEN
-
- void message( char *s )
- {
- int len, c;
- char *buf;
- len = strlen( s ) + 4;
- buf = (char *)malloc( (len + 1) * 12 );
- if( buf != NULL )
- {
- c = (80 - len)/2 /* Center box */
- W_SWAP( 10, c, 15, c + len, SCREEN, buf );
- color( BLACK, WHITE );
- wcls( 10, c, 15, c + len ); /* Clear the area */
- box( 10, c, 15, c + len, 1 ); /* Double line box */
- cup( 13, c + 2 );
- print( s ); /* Display message */
- pause();
- W_SWAP( 10, c, 15, c + len, BUFFER, buf );
- free( buf );
- }
- }
-
-
-
-
-
-
- 51
-
- ===============================================================================
-
- W_SWAP
-
- ===============================================================================
-
- Function Swap an area on the screen with memory and visa-versa.
-
- Syntax void w_swap( int ulr, int ulc, int lrr,
- int lrc, int mode, char *buffer );
-
- Prototype in mfp.h
-
- Remarks The w_swap() function requires the upper left row, upper left
- column, lower right row, lower right column of the screen
- area to be dealt with, the operational mode, and the buffer
- to store or retrieve the screen data.
-
- The mode parameter is zero for writing the screen to buffer
- and is non-zero to write the buffer to screen.
-
- The buffer MUST be large enough to accomodate the screen
- area being operated on. You can calculate the minimum buffer
- size using the following formula;
-
- (((lrc - ulc) + 1) * ((lrr - ulr) + 1)) * 2 = min buffer size.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 52
-
- ===============================================================================
-
- SCRSWP
-
- ===============================================================================
-
- Function Screen Swap
-
- Syntax void scrswp( char *buffer, int mode );
-
- Prototype in mfp.h
-
-
- Remarks Allows you to copy the screen's contents to a buffer or
- copy a buffer's contents to the screen. The mode integer
- determines which way the copy will go.
-
- If mode is non-zero, it will copy the buffer contents
- to the screen.
-
- If mode is zero, it will copy the screen contents to the
- buffer.
-
- The buffer must be at least 4000 bytes in size. Any smaller
- and data after the buffer will get wiped out.
-
-
- EXAMPLE:
-
-
- #define SCREEN 0
- #define BUFFER !SCREEN
-
- void main( void )
- {
- char buf[ 4000 ];
-
- scrswp( buf, SCREEN ); /* save the current screen */
-
- .
- .
- .
-
- scrswp( buf, BUFFER ); /* restore the screen */
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 53
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DATE AND TIME FUNCTIONS
-
- ===============================================================================
-
- DATE
-
- ===============================================================================
-
- Function Provide a character date of "MM/DD/YY"
-
- Syntax char *date( char *d_buf )
-
- Prototype in mfp.h
-
- Remarks Requires a nine character array and returns with a
- pointer to the passed array initialized with the current
- date provided by the operating system.
-
- The date is provided in the month/day/year format.
-
- The Lattice C version requires the LCR.LIB file to be
- linked because of the call to the intdos() function.
-
- EXAMPLE:
-
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- char date_buf[ 9 ];
-
- printf("The current date is %s", date( date_buf ) );
- }
-
- NOTE: Microsoft C and Quick C users, this function is not provided
- because the _strdate() function provides the same function
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 55
-
- ===============================================================================
-
- LDATE
-
- ===============================================================================
-
- Function Provide a character date of "MM/DD/YYYY"
-
- Syntax char *ldate( char *d_buf )
-
- Prototype in mfp.h
-
- Remarks Requires an eleven character array and returns with a
- pointer to the passed array initialized with the current
- date provided by the operating system.
-
- The date is provided in the month/day/year format.
-
- The difference between date() and ldate() is that ldate()
- returns with the full four character year.
-
- The Lattice C version requires the LCR.LIB file to be
- linked because of the call to the intdos() function.
-
-
- EXAMPLE:
-
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- char date_buf[ 11 ];
-
- printf("The current date is %s", ldate( date_buf ) );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 56
-
- ===============================================================================
-
- STR_JUL
-
- ===============================================================================
-
- Function Conversion from date character to date numeric.
-
- Syntax long str_jul( char *date_buf )
-
- Prototype in mfp.h
-
- Remarks Str_jul() provides an excellent method of converting a
- date string to a numeric value. The numeric value can
- be used for date mathematics or for database storage and
- sorting.
-
- Str_jul() requires the date string passed to be ten
- characters, in a "MM/DD/YYYY" format. The ldate() function
- provides a string in this format.
-
- Str_jul can accept input dates ranging from "01/01/0001" to
- "01/30/3055" inclusive.
-
-
- EXAMPLE:
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- char date_buf[ 11 ];
- long now, then;
-
- printf("The current date is %s", ldate(date_buf));
-
- now = str_jul( date_buf );
-
- then = now + 180;
-
- printf("180 days from now is %s", jul_str(then,date_buf));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 57
-
- ===============================================================================
-
- JUL_STR
-
- ===============================================================================
-
- Function Conversion from date numeric to date character.
-
- Syntax char *jul_str( long date_num, char *date_buf )
-
- Prototype in mfp.h
-
- Remarks Jul_str() provides an execellent method of converting a
- date numeric back to a string.
-
- The jul_str function returns a pointer to the date string
- passed.
-
- The input limitations for the numeric date are 1 to
- 1,115,503 for output dates ranging from "01/01/0001" to
- "01/30/3055" respectively.
-
- The date string passed must be a minimum of eleven characters.
-
-
- EXAMPLE:
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- char date_buf[ 11 ];
- long now, then;
-
- printf("The current date is %s", ldate(date_buf));
-
- now = str_jul( date_buf );
-
- then = now + 180;
-
- printf("180 days from now is %s", jul_str(then,date_buf));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 58
-
- ===============================================================================
-
- CAL_JUL
-
- ===============================================================================
-
- Function Provides a date numeric based upon the the date parameters
- provided.
-
- Syntax long cal_jul( int month, int day, int year )
-
- Prototype in mfp.h
-
- Remarks Requires three integers representing the month, day, and
- year. It returns a long integer representing the number of
- days from 01/01/0001.
-
-
- EXAMPLE:
-
- #include <mfp.h>
-
- long str_jul( char *date )
- {
- int m, d, y;
- char sub[ 5 ];
-
- m = d = y = 0;
-
- zero( sub,5 );
-
- sub[ 0 ] = date[ 0 ];
- sub[ 1 ] = date[ 1 ];
-
- sscanf( sub, "%d", &m );
-
- sub[ 0 ] = date[ 3 ];
- sub[ 1 ] = date[ 4 ];
-
- sscanf( sub, "%d", &d );
-
- sub[ 0 ] = date[ 6 ];
- sub[ 1 ] = date[ 7 ];
- sub[ 2 ] = date[ 8 ];
- sub[ 3 ] = date[ 9 ];
-
- sscanf( sub, "%d", &y );
-
- return( cal_jul( m, d, y ) );
- }
-
-
-
-
-
-
-
-
-
- 59
-
- ===============================================================================
-
- JUL_CAL
-
- ===============================================================================
-
- Function Converts a date numeric to either a day, month, or year
- integer.
-
- Syntax int jul_cal( long date_num, char *item )
-
- Prototype in mfp.h
-
- Remarks This function allows selective conversion from the date
- numeric to an integer representation of the day or month
- or the year.
-
- The selection of what is to be returned is determined by
- the second item parameter. If an "M" or "m" is passed the
- month will be returned. If a "D" or "d" is passed the day
- will be returned. If a "Y" or "y" is passed the year will
- be returned.
-
-
- EXAMPLE:
-
- #include <mfp.h>
-
- char *jul_str( long julian, char *date )
- {
- int m, d, y;
-
- m = jul_cal( julian, "M" );
- d = jul_cal( julian, "D" );
- y = jul_cal( julian, "Y" );
-
- sprintf( date, "%02d/%02d/%04d", m, d, y );
-
- return( date );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 60
-
- ===============================================================================
-
- STRTIME
-
- ===============================================================================
-
- Function Provides the time from DOS in "HH:MM:SS" format.
-
- Syntax char *strtime( char *time_buf )
-
- Prototype in mfp.h
-
- Remarks Requires a nine character buffer, the ninth character
- reserved for a terminating NULL.
-
- Returns a character pointer to the time character buffer.
-
- The Lattice C version requires the LCR.LIB file to be
- linked because of the call to the intdos() function.
-
- EXAMPLE:
-
-
- #include <mfp.h>
-
- void show_time( void )
- {
- char tbuf[ 9 ];
-
- cup( 1,70 );
- print( strtime( tbuf ) );
- }
-
- NOTE: Microsoft C and Quick C users, this function is not provided
- because the _strtime() function provides the same function.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 61
-
- ===============================================================================
-
- TIME_NUM
-
- ===============================================================================
-
- Function Provides a numeric representation of a time character string.
-
- Syntax long time_num( char *time_buf )
-
- Prototype in mfp.h
-
- Remarks Time_num() requires an eight character array representing the
- time in the format, "HH:MM:SS".
-
- Time_num() returns a long integer value that represents the
- number of seconds elapsed since midnite of the time character
- array parameter.
-
- If time_num() is passed "00:30:00" as a parameter it would
- return 1800.
-
- EXAMPLE:
-
-
- #include <mfp.h>
-
- long time_test( char *time_1, char *time_2 )
- {
- return( time_num( time_1 ) - time_num( time_2 ) );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 62
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DATA BUFFER FUNCTIONS
-
- ===============================================================================
-
- ZERO
-
- ===============================================================================
-
- Function Fills a character array with NUL's.
-
- Syntax void zero( char *array, int array_length );
-
- Prototype in mfp.h
-
-
- Remarks Handy function to initialize a buffer before or after use.
-
- Be careful with the length parameter - if it's too long,
- it may wipe out other data because you will make it initial-
- ize data after the array.
-
-
- EXAMPLE:
-
-
- void main( void )
- {
- char buf[ 80 ];
-
- do
- {
- zero( buf, 80 );
-
- gets( buf );
-
- printf("%s\n",buf);
- }
- while( buf[ 0 ] );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 64
-
- ===============================================================================
-
- FILL
-
- ===============================================================================
-
- Function Initialize a block of data with a specific character.
-
- Syntax void fill( char *block, int length, char character );
-
- Prototype in mfp.h
-
- Remarks The fill() function requires the pointer to the block of data
- to be initialized, the length of the block, and the character
- to initialize it with.
-
- Be careful with the length parameter. It can damage your
- code if it overruns the data you wanted to initialize.
-
- EXAMPLE:
-
-
- void main( void )
- {
- char buf[ 80 ];
-
- do
- {
- fill( buf, 80, 'A' );
-
- printf("%s\n",buf);
- }
- while( buf[ 0 ] );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 65
-
- ===============================================================================
-
- CRC & CRC32
-
- ===============================================================================
-
- Function Provide a 16 or 32 bit Cyclic Rendundancy Check of a block of
- data. Useful for error checking of any I/O process moving a
- block of data.
-
- Syntax unsigned int crc( char *block, int length );
- unsigned long crc32( char *block, int length );
-
- Prototype in mfp.h
-
- Remarks Both crc() and crc32() scan a block of data and perform an
- algorythm using the data as input to a polynomial equation.
-
- The result of the polynomial is the "crc". This value can
- be used to validate the accuracy of a data block if the "crc"
- was transmitted along with the data block. It can also be
- used to check if a data record is corrupt. The 32 bit crc
- generated by crc32() is more thorough and provides better
- accuracy than it's 16 bit cousin, crc(). This is mainly due
- to the size of the resultant polynomial.
-
- EXAMPLE:
-
- #include <stdio.h>
- #include <mfp.h>
-
- unsigned int block_ck( char *block, int len, unsigned int crc )
- {
- /*
- Compare the passed crc with the current crc
- of the data block.
- */
- return( crc( block,len ) - crc );
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 66
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MISCELLANEUOS FUNCTIONS
-
- ===============================================================================
-
- BRKOFF & BRKON
-
- ===============================================================================
-
- Function To disable or reenable the break key
-
- Syntax void brkoff( void )
- void brkon( void )
-
- Prototype in mfp.h
-
- Remarks These functions allow you to turn off the break or ctrl C
- keys thereby avoiding possible disaster if the users attempted
- to "break" out, leaving the machine in an undefined state or
- vectors pointing to nowhere.
-
- The brkoff() function is called first to disable the break key.
-
- The brkoff() function works by intercepting the hardware
- keyboard interrupt and checking the scan codes coming from
- the keyboard. If it senses a key sequence that would activate
- the DOS control break routines, this function would "bit-bin"
- the keystroke as though it never occurred.
-
- The brkon() function turns the break key on again.
-
- The brkon() function disengages the brkoff() function by
- removing its chain into the keyboard interrupt. THIS FUNCTION
- MUST BE CALLED PRIOR TO RETURNING TO DOS IF BRKOFF() IS USED.
-
- If you neglect to call brkon() the keyboard will cease to func-
- tion, requiring you to cold boot the computer.
-
- The brkoff() and brkon() functions use interrupt vector 9.
-
- WARNING: This function intercepts interrupt vectors that may
- ======== be used by other functions in this library. This makes
- it very important that you disengage this function in
- the reverse order it was engaged in. This will insure
- the integrity of the interrupt vectors upon return to
- DOS. EXAMPLE:
- brkoff(); /* Turn off break key */
- scrsave(); /* Screen saver */
- showclok(); /* Real time clock */
- .
- .
- noclok(); /* Disengage clock */
- nosave(); /* Disengage scrn saver */
- brkon(); /* Turn break key on */
-
-
-
-
-
-
-
-
- 68
-
- ===============================================================================
-
- SCRSAVE & NOSAVE
-
- ===============================================================================
-
- Function Turns display off after time period of no keyboard activity.
-
- Syntax void scrsave( int tenths );
- void nosave( void );
-
- Prototype in mfp.h
-
- Remarks The scrsave() function requires an integer value representing
- the time in tenths of a second, to wait before blanking the
- display. The purpose for this function is to increase the
- amount of time before your main menu makes a permanent im-
- pression on the phosphors of the users monitor. It accomplishes
- this task by waiting the required time after each keypress
- until the time expires. It then stores the attribute bytes in
- screen memory to a 2k buffer and then writes out a BLACK on
- BLACK attribute in the originals place. This makes the screen
- look like it has been turned off and it effectively will pre-
- vent screen burn. When a subsequent keypress occurs, this func-
- tion will write the stored attributes back out into screen
- memory effectively restoring the original screen.
-
- The nosave() function is used to disengage the scrsave()
- function. THIS FUNCTION MUST BE CALLED PRIOR TO RETURNING TO
- DOS IF scrsave() IS USED.
-
- The scrsave() function intercepts interrupt vectors 9 and 1CH.
-
- WARNING: This function intercepts interrupt vectors that may
- ======== be used by other functions in this library. This makes
- it very important that you disengage this function in
- the reverse order it was engaged in. This will insure
- the integrity of the interrupt vectors upon return to
- DOS. EXAMPLE:
- brkoff(); /* Turn off break key */
- scrsave(); /* Screen saver */
- showclok(); /* Real time clock */
- .
- .
- noclok(); /* Disengage clock */
- nosave(); /* Disengage scrn saver */
- brkon(); /* Turn break key on */
-
-
-
-
-
-
-
-
-
-
-
-
- 69
-
- ===============================================================================
-
- SHOWCLOK & NOCLOK
-
- ===============================================================================
-
- Function Displays the current time on the screen every second.
-
- Syntax void showclok( int row, int col, int fg, int bg );
- void noclok( void );
-
- Prototype in mfp.h
-
- Remarks The showclok() function requires the row, column, foreground
- attribute, and background attribute. It will display the
- time continuously until you disengage it. It is a background
- task that will not interfere or measurably affect your app-
- lication. It provides a nice eight character digital presen-
- tation, HH:MM:SS.
-
- The noclok() function is used to disengage the showclok()
- function. THIS FUNCTION MUST BE CALLED PRIOR TO RETURNING TO
- DOS IF showclok() IS USED.
-
- The showclok() function intercepts interrupt vector 1CH.
-
- WARNING: This function intercepts interrupt vectors that may
- ======== be used by other functions in this library. This makes
- it very important that you disengage this function in
- the reverse order in which it was engaged. This will
- insure the integrity of the interrupt vectors upon
- return to DOS.
- EXAMPLE:
- brkoff(); /* Turn off break key */
- scrsave(); /* Screen saver */
- showclok(); /* Real time clock */
- .
- .
- noclok(); /* Disengage clock */
- nosave(); /* Disengage scrn saver */
- brkon(); /* Turn break key on */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 70
-
- ===============================================================================
-
- DELAY
-
- ===============================================================================
-
- Function Delay for a period of time
-
- Syntax void delay( unsigned clicks );
-
- Prototype in mfp.h
-
- Remarks The delay function provides an exact delay in 55 millisecond
- increments. The delay function uses the internal clock timer
- to establish its operation. The unsigned parameter is the
- number of 55 millisecond clock ticks to wait. The clock
- ticks at a rate of 18.2 ticks per second. A typical 1/2
- second delay would pass a parameter value of nine.
-
- EXAMPLE
-
-
- #include <stdio.h>
- #include <mfp.h>
-
- void main( void )
- {
- unsigned ticks;
-
- printf("Please standby, waiting 10 seconds...");
-
- ticks = 182;
-
- delay( ticks );
-
- printf("\n\nThankyou for your patience.");
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 71
-
-
- ----------------end-of-author's-documentation---------------
-
- Software Library Information:
-
- This disk copy provided as a service of
-
- The Public (Software) Library
-
- We are not the authors of this program, nor are we associated
- with the author in any way other than as a distributor of the
- program in accordance with the author's terms of distribution.
-
- Please direct shareware payments and specific questions about
- this program to the author of the program, whose name appears
- elsewhere in this documentation. If you have trouble getting
- in touch with the author, we will do whatever we can to help
- you with your questions. All programs have been tested and do
- run. To report problems, please use the form that is in the
- file PROBLEM.DOC on many of our disks or in other written for-
- mat with screen printouts, if possible. The P(s)L cannot de-
- bug programs over the telephone.
-
- Disks in the P(s)L are updated monthly, so if you did not get
- this disk directly from the P(s)L, you should be aware that
- the files in this set may no longer be the current versions.
-
- For a copy of the latest monthly software library newsletter
- and a list of the 2,000+ disks in the library, call or write
-
- The Public (Software) Library
- P.O.Box 35705
- Houston, TX 77235-5705
- (713) 524-6394
-